package com.ruoyi.stuclass.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stuclass.domain.Stuclass;
import com.ruoyi.stuclass.service.IStuclassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 辅导员管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-22
 */
@RestController
@RequestMapping("/stuclass/stuclass")
public class StuclassController extends BaseController
{
    @Autowired
    private IStuclassService stuclassService;

    /**
     * 查询辅导员管理列表
     */
    @PreAuthorize("@ss.hasPermi('stuclass:stuclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(Stuclass stuclass)
    {
        startPage();
        List<Stuclass> list = stuclassService.selectStuclassList(stuclass);
        return getDataTable(list);
    }

    /**
     * 导出辅导员管理列表
     */
    @PreAuthorize("@ss.hasPermi('stuclass:stuclass:export')")
    @Log(title = "辅导员管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Stuclass stuclass)
    {
        List<Stuclass> list = stuclassService.selectStuclassList(stuclass);
        ExcelUtil<Stuclass> util = new ExcelUtil<Stuclass>(Stuclass.class);
        util.exportExcel(response, list, "辅导员管理数据");
    }

    /**
     * 获取辅导员管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('stuclass:stuclass:query')")
    @GetMapping(value = "/{classnum}")
    public AjaxResult getInfo(@PathVariable("classnum") String classnum)
    {
        return AjaxResult.success(stuclassService.selectStuclassByClassnum(classnum));
    }

    /**
     * 新增辅导员管理
     */
    @PreAuthorize("@ss.hasPermi('stuclass:stuclass:add')")
    @Log(title = "辅导员管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Stuclass stuclass)
    {
        return toAjax(stuclassService.insertStuclass(stuclass));
    }

    /**
     * 修改辅导员管理
     */
    @PreAuthorize("@ss.hasPermi('stuclass:stuclass:edit')")
    @Log(title = "辅导员管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Stuclass stuclass)
    {
        return toAjax(stuclassService.updateStuclass(stuclass));
    }

    /**
     * 删除辅导员管理
     */
    @PreAuthorize("@ss.hasPermi('stuclass:stuclass:remove')")
    @Log(title = "辅导员管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{classnums}")
    public AjaxResult remove(@PathVariable String[] classnums)
    {
        return toAjax(stuclassService.deleteStuclassByClassnums(classnums));
    }
}
